package com.example.shopping.pojo.result;

/**
 * 作为相应的消息的一个类
 * @author 瓶盖
 */
public class Result {
    /**
     * 状态 200 成功 404 未找到 500 错误消息
     */
    private int code;
    /**
     * 作为消息返回的提醒
     */
    private String message;
    /**
     * 返回给页面的 数据
     */
    private Object data;

    public Result() {
    }

    public Result(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Result success() {
        return new Result(200, "操作成功");
    }

    public static Result success(Object data) {
        return new Result(200, "操作成功", data);
    }
    public static Result fail(int code, String message) {
        return new Result(code, message);
    }
    public static Result fail(String message) {
        return new Result(500, message);
    }
}